package tests;

import common.Utils;
import org.openqa.selenium.By;

public class ListPage extends Utils {
    private static String url = "http://139.196.34.232:8080/blog_list.html";
    public ListPage() {
        super(url);
    }

    //未登录状态, 会跳转到登录页面
    public void PageByNoLogin() throws InterruptedException {
//        //这里是在登录成功后调用的,所以要先点击注销,
//        // 再直接跳转到列表页, 然后会再跳转到登录页
        driver.findElement(By.cssSelector("body > div.nav > a:nth-child(6)")).click();
//
//        Thread.sleep(2000);
//        String curl = driver.getCurrentUrl();
//        System.out.println(curl);
//
        driver.get("http://139.196.34.232:8080/blog_list.html");


        driver.findElement(By.cssSelector("body > div.container-login > div > h3"));
        driver.findElement(By.cssSelector("#username"));
    }


    //页面加载成功
    public void ListPageRight(){
//        //目前在登录页, 输入正确账号密码, 跳转到列表页
//        driver.findElement(By.cssSelector("#username")).sendKeys("zhangsan");
//        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
//        driver.findElement(By.cssSelector("#submit")).click();
        driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a"));


        String curl = driver.getCurrentUrl();
        assert (curl.equals("http://139.196.34.232:8080/blog_list.html") == true);

    }

}
